package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.Quarter;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 每年季度 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2024-03-20
 */
public interface QuarterMapper extends BaseMapper<Quarter> {

    /**
     * 获取上一个季度
     *
     * @param yearPart
     * @param quarterNum
     * @return
     */
    @Select("select * from `quarter` where id < (select id from `quarter` where year_part = ${yearPart} and num =${quarterNum} limit 1) ORDER BY id desc limit 1")
    public Quarter getLastQuarter(@Param("yearPart") Integer yearPart, @Param("quarterNum") Integer quarterNum);

}
